let sum = "rtyuiopasdfghjklzxcvbnm";
let fs = require("fs");
let fd = fs.openSync("xxx.txt", 'w');
for (let i = 0; i < 100; i++) {
    let long = Math.ceil(Math.random()*10);
    let kongSum = '';
    for (let j = 0; j < long; j++) {
        let suiSum = Math.ceil(Math.random() * sum.length);
        kongSum += sum.charAt(suiSum);
    }
    fs.writeSync(fd, kongSum, { flag: 'a' })
}
fs.closeSync(fd);

let newSum = [];
let rs = fs.createReadStream('xxx.txt', 'utf-8');
rs.on("data", (chunk) => {
    console.log(chunk);
    let newSum1 = chunk;
    for (let k = 0; k < newSum1.length; k++) {
        if (newSum[newSum1[k]]) {
            newSum[newSum1[k]]++;
        }else{
            newSum[newSum1[k]]=1;
        }
    }
        var char = '';
        var max = 0;
        for(var key in newSum){
            if(max < newSum[key]){
                max = newSum[key]
                char = key;
            }
        }
        console.log("此次出现最多的字符是"+char);
    });
   